<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { listCartInfosByPageUsingPost } from '@/api/cartController.ts'
import { message } from 'ant-design-vue'
import ImageList from '@/components/ImageList.vue'

const searchParams = ref<API.PageDto>({
  current: 1,
  pageSize: 12,
})

const loading = ref(false)
const cartList = ref<API.CartVo[]>([])

// 加载数据
const loadData = async () => {
  loading.value = true
  const res = await listCartInfosByPageUsingPost({
    ...searchParams.value,
  })
  if (res.code === 200 && res.data) {
    cartList.value = res.data.records as API.CartVo[]
  } else {
    message.error(res.message)
  }
  loading.value = false
}

onMounted(() => loadData())
</script>

<template>
  <div id="cart-manage-view">
    <image-list :loading="loading" :data-list="cartList" :on-reload="loadData" :show-op="true" />
  </div>
</template>

<style scoped></style>
